<?php
class stockController extends RPHP_Controller
{
    //我的库存
    public function index()
    {
        $m    = $this->model;
        $user = $m->checkAuth();
        if ($user) {

            $this->view->data  = $m->getAllGoods();
            $this->view->stock = $m->getStock();
            $this->display();
        }
    }

    // 出货库存
    public function transfer()
    {
        $m    = $this->model;
        $user = $m->checkAuth();
        if ($user) {

            $goods_id = intval($_GET['goods_id']);
            if ($goods_id > 0) {

                $this->view->goods_id = $goods_id;
                $this->view->data     = $m->getAllGoods();
                $this->view->stock    = $m->getStock(0,$goods_id);
                $this->display();
            }

        }
    }

    // AJAX
    public function ajax()
    {
        $data['code'] = 900;

        $m    = $this->model;
        $user = $m->checkAuth(false);
        if ($user) {

            if($_POST['act']=="check")
            {
                $data = $m->checkMobile(addslashes($_POST['mobile']));
            }
            elseif($_POST['act']=="transfer")
            {
                $data = $m->transferStock($_POST);
            }
            elseif($_POST['act']=="getsetting")
            {
                $data = $m->getAgentSetting($_POST);
            }



        }

        echo json_encode($data);
    }

}
